package com.tanjun.thirdservice.web.service.wx.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum WxCodeEnum {
    OK(0,"成功"),
    BUSY(-1,"网络繁忙"),
    TOKEN_ERR(40001, "token无效"),

    OTHER(9999, "其他异常")
    ;

    private int code;
    private String msg;

    public static WxCodeEnum valueFrom(int code){
        return Arrays.stream(WxCodeEnum.values()).filter(t -> t.getCode() == code).findAny().orElse(OTHER);
    }
}
